<!DOCTYPE html>
<html lang="en">

<head>
    {include file="mobile/public/resource" /}    
    <link rel="stylesheet" href="__INDEX__/mobile/css/hyzxzc.css">
    <script src="//captcha.luosimao.com/static/js/api.js"></script>
    <script src="__INDEX__/js/register_messages.js"></script>
</head>

<body>
    {include file="mobile/public/header" /} 
    <!-- <div class="banner"><img src="__INDEX__/mobile/img/gyzcy/banner.png"></div> -->
    <div class="main">
        <div class="d_center">
            <img src="__INDEX__/mobile/img/hyzcy/zc.png" style="display: block!important;margin:0 auto;margin-top: 3rem;">
        </div>
    </div>
    <div class="yy layui-form">
            <div class="sle1 sles">
                <span>手&nbsp;机&nbsp;号:</span>
                <input type="text" class="layui-input phone" placeholder="手机号"  lay-verify="phone"  name="phone">
            </div>
            <div class="sle2 sles types">
                <span>随&nbsp;机&nbsp;码:</span>
                <div class="l-captcha" data-site-key="c35f80e3aeb63b54fdac9db0fd6a3f2b"  data-callback="getResponse" data-width="100%"></div>
            </div>
            <div class="sle4 ">
                <span>验&nbsp;证&nbsp;码:</span>
                <input type="text" class="layui-input" onfocus="if(value=='请输入验证码') {value=''}" onblur="if (value=='') {value='请输入验证码'}" placeholder="验证码"  lay-verify="yzm" style="width: 70%;" name="yzm">
                <div id="getYzm"  onclick="send_capicha_regist()">获取验证码</div>
            </div>
            <div class="sle5 sles">
                <span>密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码:</span>
                <input type="password" placeholder="密码" class="layui-input"  lay-verify="password" name="password">
            </div>
            <div class="sle6 sles">
                <span>确认密码:</span>
                <input type="password" class="layui-input" placeholder="确认密码"  lay-verify="passwords" name="ypassword">
            </div>
            <!-- <div class="sle7 sles">
                <span></span>
                <div style="width: 100%;">
                    <input type="radio" name="sex" value="先生" title="先生" checked>
                      <input type="radio" name="sex" value="女士" title="女士" >
                </div>
            </div>
            <div class="sle8 sles">
                <span>姓名:</span>
                <input type="text" class="layui-input" placeholder="姓名"  lay-verify="name" name="name">
            </div>
            <div class="sle9 sles">
                <span>证件类型:</span>
                <select value="" name="type" id="type" lay-filter="" lay-verify="types">
                    <option value="身份证">身份证</option>
                    <option value="驾驶证">驾驶证</option>
                </select>
            </div>
            <div class="sle10 sles">
                <span>证件号码:</span>
                <input type="text" class="layui-input" placeholder="证件号码" lay-verify="typenum">
            </div> -->
            <button class="layui-btn" lay-submit lay-filter="tj" style="display: block;margin: 0 auto;margin-top: 40px;">立即提交</button>
        </div>
    {include file="mobile/public/footer" /} 





    <script>
       layui.use('form', function(){
  var form = layui.form;

	//各种基于事件的操作，下面会有进一步介绍
	//
	//
	//
	//自定义验证规则  
  form.verify({  
	    phone: function(value){
            if(value==''){
                return '请输入手机号';
            }
        },yzm: function(value){
            if(value==''){
                return '请输入验证码';
            }
        },password: function(value){
        	passwords = value;
            if(value==''){
                return '请输入密码';
            }
        },passwords: function(value){
            if(value==''){
                return '请确认密码';
            }else if(value != passwords){
            	return '两次密码不一致'
            }
        },name: function(value){
            if(value==''){
                return '请输入姓名';
            }
        }
        ,phone: [/^1[3|4|5|7|8]\d{9}$/, '手机必须11位，只能是数字！']  
  });  



	//监听提交
	form.on('submit(tj)', function(data){
		if(resps == undefined || resps == ''){alert('请验证随机码');return false;}
		console.log(data);
	 	$.ajax({
	        type: 'POST',
	        dataType:'json',
	        url : '{:url('Login/reg')}',
	        data: {
	        	phone:data.field.phone,
	        	yzm:data.field.yzm,
	        	password:data.field.password,
	        	ypassword:data.field.ypassword
	        },
	        success: function(data){
	        	if(data==5){
	       			layer.msg('注册成功', {icon: 6,time:2000,end:function () {
                            	window.location.href='http://aoling.douyar.cc/index/login/index.html'; //要跳转到登录页面
                            }
	       			});
	       		}else if(data == 1){
	       			layer.msg('验证码错误', {icon: 2,time:2000,end:function () {
                            }
	       			});
	       		}else if(data == 2){
	       			layer.msg('验证码过期', {icon: 2,time:2000,end:function () {
                            }
	       			});
	       		}else if(data == 6){
	       			layer.msg('手机号已存在', {icon: 2,time:2000,end:function () {
                            }
	       			});
	       		}
	        }
	    });
	});
});
var resps;
function getResponse(resp){
	console.log(resp);
	console.log(resps);
      // resp 即验证成功后获取的值
     resps = resp;
}
    </script>









</body>

</html>